package com.zhiyou.controller;

import com.zhiyou.entity.News;
import com.zhiyou.util.NewsUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

/**
 * @author sanshi
 * @desc
 * @create 2021-09-15 23:56
 */
@WebServlet("/DoGetNews")
public class DoGetNews extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String selectCid = req.getParameter("selectCid");
        ArrayList<News> newsList = new NewsUtil().getNewsByColnID(selectCid);
        req.getSession().setAttribute("newsList",newsList);
        resp.sendRedirect("/page/AllNews.jsp");
    }
}
